/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */
package info.peigen.hotpot.component.doc.core.config;

import cn.hutool.core.util.ObjUtil;
import info.peigen.hotpot.component.doc.core.annotation.Api;
import info.peigen.hotpot.component.doc.core.publish.HotpotDocPublish;
import info.peigen.hotpot.component.doc.core.resolver.HotpotApiResolver;
import org.noear.solon.Solon;
import org.noear.solon.annotation.Component;
import org.noear.solon.annotation.Init;

/**
 * <b>(HotpotDocInit)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2023/12/1
 */
@Component
public class HotpotDocInit {

    @Init
    public void init() throws Throwable {
        Solon.context().beanForeach(bean -> {
            Api api = bean.annotationGet(Api.class);
            if (ObjUtil.isNotEmpty(api)) {
                HotpotDocPublish.doc.getApis().add(HotpotApiResolver.resolver(api));
            }
        });
    }

}